/*
 * @Author: wen.ligang
 * @Date: 2019-11-08 18:35:50
 * @LastEditTime: 2019-11-08 19:29:25
 * @LastEditors: Please set LastEditors
 * @Description: read date from .csv file
 * @FilePath: /cartographer_interface/src/file_read.h
 */

#ifndef __FILE_READ_H
#define __FILE_READ_H

#include <iostream>
#include <vector>
#include <math.h>
#include <stdint.h>

using namespace std;


struct Header{
        uint32_t seq;
        timespec stamp;
        string frame_id;
    };
struct UlOdomImu_t{
    Header header;
    float           rollAngle; // 翻转角
    float           pitchAngle;// 俯仰角
    float           yawAngle;  // 偏航角
    float           xGyro;// 陀螺仪 x
    float           yGyro;// 陀螺仪 y
    float           zGyro;// 陀螺仪 z
    float           xAccelerometer;// 加速度计 x
    float           yAccelerometer;// 加速度计 y
    float           zAccelerometer;// 加速度计 z
    float           xMagneticCompass;// 磁罗盘 x
    float           yMagneticCompass;// 磁罗盘 y
    float           zMagneticCompass;// 磁罗盘 z
    float   rWheelEncoder;// 右轮编码器
    float   lWheelEncoder;// 左轮编码器
    float  xSum;// x 轴累计
    float  ySum;// y 轴累计
};// IMU 陀螺仪相关参数 码盘数
struct LaserMessage {
        Header header;
        float angle_min;
        float angle_max;
        float angle_increment;
        float time_increment;
        float scan_time;
        float range_min;
        float range_max;
	int range_nums;
        vector<float> ranges;
	vector<float> angles;
        vector<float> intensities;
    };

class csvFileRead
{
    
    public: 
        csvFileRead() {};    
        bool read_csv_file(string fileName,vector<LaserMessage> &LaserMsg);
        bool read_csv_file(string fileName,vector<UlOdomImu_t> &UlOdomImu_t);
        bool write_csv_file(string fileName,vector<LaserMessage> &LaserMsg);
        bool write_csv_file(string fileName,vector<UlOdomImu_t> &UlOdomImu_t);
    private:
        inline string cutString(string str, int lor);
        inline string Trim(string &str);
        inline float string_to_float(string str);
};

#endif
